<template>
    <div>
        <h1>修改患者信息</h1>
        <el-form ref="form" :rules="rules"  :model="form" label-width="80px">
            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="姓名" >
                        <el-input v-model="form.name"></el-input>
                    </el-form-item>  
                </el-col>
                <el-col :span="12">
                    <el-form-item label="性别">
                        <el-radio-group v-model="form.gender">
                            <el-radio :label="0">女</el-radio>
                            <el-radio :label="1">男</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="身份证" prop="">
                        <el-input v-model="form.idcard"></el-input>
                    </el-form-item>  
                </el-col>
                <el-col :span="12">
                    <el-form-item label="年龄">
                        <el-input-number v-model="form.age" :min="1" :max="100" ></el-input-number>
                    </el-form-item> 
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="电话号码" prop="">
                        <el-input v-model="form.phone"></el-input>
                    </el-form-item>  
                </el-col>
                <el-col :span="12">
                    <el-form-item label="住院时间">
                        <span class="demonstration"></span>
                            <el-date-picker v-model="form.zytime" type="date" placeholder="选择日期"></el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="治疗养院">
                        <el-input v-model="form.hospital"></el-input>
                    </el-form-item>  
                </el-col>
                <el-col :span="12">
                    <el-form-item label="是否重症">
                        <el-radio-group v-model="form.isNotHealthy">
                            <el-radio :label="0">否</el-radio>
                            <el-radio :label="1">是</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="感染来源">
                        <el-input v-model="form.grfrom"></el-input>
                    </el-form-item>  
                </el-col>
                <el-col :span="12">
                    <el-form-item label="症状" prop="">
                        <el-input v-model="form.zhengz"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="住址" prop="">
                        <el-input v-model="form.address"></el-input>
                    </el-form-item>  
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="12"> 
                    <el-form-item label="备注">
                        <el-input type="textarea" v-model="form.desc" rows="4" placeholder="请输入" maxlength="200" show-word-limit></el-input>
                    </el-form-item>  
                </el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" >提交</el-button>
                <el-button @click="quxiao">取消</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>
<script>
import request from '@/utils/request'
  export default {
    data() {
      return {
        form: 
        {
            name:'',
            gender:'',
            idcard:'',
            age:undefined,
            phone:'',
            zytime:'',
            hospital:'',
            isNotHealthy: 1,
            grfrom:'',
            zhengz:'',      
            address:'',
            desc: ''
        },
        rules:{
            name: [
            { required: true, message: '请输入姓名', trigger: 'blur' },
            { min: 1, max: 15, message: '长度在 1 到 15 个字符', trigger: 'change' }
          ],
          phone: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { min: 11, max: 11, message: '长度在11 个字之内', trigger: 'change' },
           
          ],
        }
      }
    },
    created(){
      this.fetchData()
    },
    methods: {
      fetchData() {
          request({
              url:'../patient_info.json',
              method:'get'
          }).then((response)=>{
              this.form=response.data
            // console.log(response.data)
          })
        },
        quxiao(){
            history.go(-1)
        }
    }
  }
</script>
